package com.wildworld.main;
import com.wildworld.core.services.IMapService;
import com.wildworld.core.services.IWorldService;
import com.wildworld.core.worldobjects.WorldObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
 * @author gzhebrakov
 *         Date: 26.06.12
 *         Time: 19:29
 *         application entry point
 */

@Service
public final class ApplicationRunner {

    private static ApplicationRunner instance;

    private IWorldService worldService;

    private IMapService mapService;

    @Autowired
    public void setWorldService(IWorldService worldService){
        this.worldService = worldService;
    }

    @Autowired
    public void setMapService(IMapService mapService){
        this.mapService = mapService;
    }

    public IWorldService getWorldService(){
        return worldService;
    }

    public IMapService getMapService(){
        return mapService;
    }

    private ApplicationRunner(){}

    public void start(){
        WorldObject obj = new WorldObject();
        if (worldService.getWorld() != null){
            Thread worldThread = new Thread(worldService.getWorld());
            worldThread.start();
        }else {
            throw new NullPointerException("world instance is null");
        }
    }
}
